package com.kfm.wiki.ex;

import com.kfm.wiki.util.R;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
public class ExceptionAdvice {


    @ExceptionHandler(BussinessException.class)
    @ResponseBody
    public R doBuEx(BussinessException e){
        return R.failed(e.getMessage() == null? "服务器异常，请重试": e.getMessage());
    }

    @ExceptionHandler(Exception.class)
    @ResponseBody
    public R doEx(Exception e){
        e.printStackTrace();
        return R.failed(e.getMessage() == null? "服务器异常，请重试": e.getMessage());
    }

}
